<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCasesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cases', function (Blueprint $table) {
            $table->engine = 'InnoDB';

            $table->increments('id');
            $table->string('case_type');
            $table->string('title');
            $table->text('desc');
            $table->string('name');
            $table->string('age');
            $table->boolean('sex');
            $table->integer('province_id')->unsigned()->index('province_id');
            $table->integer('city_id')->unsigned()->index('city_id');
            $table->string('manner');
            $table->date('time');
            $table->float('height');
            $table->string('picture');
            $table->text('introduce');
            $table->string('history');
            $table->string('user_name');
            $table->timestamps();

            $table->foreign('province_id')
                  ->references('id')
                  ->on('provinces')
                  ->onDelete('cascade');

            $table->foreign('city_id')
                  ->references('id')
                  ->on('citys')
                  ->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('cases');
    }
}
